"""
Definitions for datastore classes.
"""
_author_ = 'pablo@google.com'

#from google.appengine.api import users
from google.appengine.ext import db

class MedRecordModel(db.Model):
  # System fields - when record was created, and by whom, when it was
  # last updated, and by whom
  create_time = db.DateTimeProperty(auto_now_add=True)
  create_user = db.UserProperty(auto_current_user_add=True)
  update_time = db.DateTimeProperty(auto_now=True)
  update_user = db.UserProperty(auto_current_user=True)

class PID(MedRecordModel):
  """Patient ID records."""
  given_name = db.StringProperty()
  family_name = db.StringProperty()
  gender = db.StringProperty()
  dob = db.DateProperty()
  voter_id = db.StringProperty()
  mobile_number = db.PhoneNumberProperty()
  visit_location = db.StringProperty() # should these be PostalAddressProperty?
  living_location = db.StringProperty()
  notes  = db.TextProperty()
  

class Procedure(MedRecordModel):
  """Procedure or surgery records."""
  pid = db.ReferenceProperty(PID)  # to which PID this is linked

  proc_name = db.StringProperty()
  date = db.DateProperty()
  notes = db.TextProperty()
  
